package com.exist.simple.demo.controller;

import com.alibaba.fastjson.JSON;
import com.exist.simple.demo.dto.ClassInfoDTO;
import com.exist.simple.demo.service.ClassInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "/classInfo")
public class ClassInfoController {

    private static Logger logger = LoggerFactory.getLogger(ClassInfoController.class);

    @Autowired
    ClassInfoService classInfoService;

    @GetMapping("/class")
    public String classInfo(HttpServletRequest request) {
        logger.info("/classInfoDTO start");
        ClassInfoDTO classInfoDTO = classInfoService.classInfo();
        logger.info("/classInfoDTO end, response: {}", JSON.toJSONString(classInfoDTO));
        return JSON.toJSONString(classInfoDTO);
    }

}
